package top.fyukina.fyson.runtime.loader;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;

public final class ModuleLoader {
    private URLClassLoader classLoader;
    private ModuleLoader() {}
    public void load(List<Module> modules) throws MalformedURLException {
        URL[] urls = new URL[modules.size()];
        for (int i = 0; i < modules.size(); i++)
            urls[i] = new URL(modules.get(i).getJar());
        classLoader = new URLClassLoader(urls);
    }
    static class Module {
        private String name, jar, className;
        public void setName(String name) {
            this.name = name;
        }
        public void setJar(String jar) {
            this.jar = jar;
        }
        public void setClassName(String className) {
            this.className = className;
        }
        public String getName() {
            return name;
        }
        public String getJar() {
            return jar;
        }
        public String getClassName() {
            return className;
        }
    }
}